package org.tedu.controller;


import org.tedu.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.tedu.mapper.UserMapper;

import java.util.List;
import java.util.Map;

/**
 * Author：程Sir
 * Name： SpringTest01
 * Content:
 */
@Controller
public class UserController {
//    @Resource
    @Autowired
    private UserMapper userMapper;

    public void selectOne(Integer id){
        User u = userMapper.findUserById(id);

        System.out.println("获取的数据是："+u);
    }

    public void selectAll(){
        List<User> u = userMapper.findUsers("t_user");
        System.out.println("获取的数据是："+u);
    }

    public void addUser(User user){
        int row = userMapper.insertUser(user);
        System.out.println("影响的行数是："+row);
    }


    public void deleteUser(Integer id){
        int row = userMapper.deleteUserById(id);
        System.out.println("影响的行数是："+row);
        System.out.println("影响的行数是："+row);
    }
    public void updateUser(Integer id){
        int row = userMapper.updateUserById(id);
    }

    public void updateEmailById(Integer id, String email){
        int row = userMapper.updateEmailById(id, email);
        System.out.println("影响的行数是："+row);
    }

    public void deleteUsersById(List<Integer> list) {
        int row = userMapper.deleteUsersById(list);

        System.out.println("影响的行数是："+row);
    }
}
